package main

import (
	"fmt"
	"sort"
)

//map排序

func main() {
	testMap3()
}

func testMap3() {
	a := make(map[int]int)

	a[1] = 3
	a[5] = 6
	a[3] = 19
	a[44] = 9
	a[2] = 8
	var keys []int
	for k, _ := range a {
		keys = append(keys, k)
	}
	sort.Ints(keys)
	for _, v := range keys {
		fmt.Printf("k=%d,v=%d\n", v, a[v])
	}
	fmt.Println()
	for k, v := range a {
		fmt.Printf("k=%d,v=%d\n", k, v)
	}
}
